#ifndef MATITEM_H
#define MATITEM_H

#include <QGraphicsRectItem>
#include "matwin_global.h"

class MATWINSHARED_EXPORT MatItem : public QGraphicsRectItem
{
public:
    enum Type {
        kTypeEmpty = 0,
        kTypeFill,
        kTypeCustom = 65536,
    };
    enum DataType {
        kDataPos = 0,
    };
    using ColorMap = QMap<qint32, QColor>;

    MatItem(const QRectF &rect, QGraphicsItem *parent = Q_NULLPTR);
    ~MatItem();

    virtual void paint(QPainter *painter,
                       const QStyleOptionGraphicsItem *option,
                       QWidget *widget = 0);

    int type() const { return UserType + 1; }

    qint32 itemType() const { return m_type; }
    void setItemType(qint32 type) { m_type = type; }

    QColor color(qint32 type) const {
        return m_colorMap[type];
    }
    void setColor(qint32 type, const QColor &color) {
        m_colorMap[type] = color;
    }

    QPoint position() {
        return data(kDataPos).toPoint();
    }

private:
    qint32 m_type;
    ColorMap m_colorMap;
};

#endif // MATITEM_H
